/**
 * @example
 * await useRequest(deleteContactApi, {
 *       id: val.id
 *     })
 *
 * @param request
 * @param args
 * @returns {Promise<{loading: *, res: *}>}
 */
export async function useRequest(request, ...args) {
  const loading = ref(false);
  const res = ref();
  try {
    loading.value = true;
    res.value = await request(...args);
  } catch (e) {
    console.log(e);
  } finally {
    loading.value = false;
  }
  return {
    loading,
    res,
  };
}
